/*
 * @Description: provider
 * @Autor: lcz
 * @Date: 2022-08-15 10:06:05
 * @LastEditors: lcz
 * @LastEditTime: 2022-08-15 10:24:00
 */
import * as React from 'react'

export type DisabledType = true | false | undefined

const DisabledContext = React.createContext<DisabledType>(false)

export interface DisabledContextProps {
  disabled?: DisabledType
  children?: React.ReactNode
}

export const DisabledContextProvider: React.FC<DisabledContextProps> = ({ children, disabled }) => {
  const originDisabled = React.useContext(DisabledContext)
  return <DisabledContext.Provider value={disabled || originDisabled}>{children}</DisabledContext.Provider>
}

export default DisabledContext
